#ifndef _CONFIG_BASE_HPP_20120608
#define _CONFIG_BASE_HPP_20120608

#include "utility.hpp"

	#define get_param_str(config, session, key, to_value, is_empty_ok)\
	do{\
		int rv=config.get_string_param(session,key,to_value);\
		if( rv!=0 )\
		{\
			cerr<<"read configure fail[session: "<<session<<", key: "<<key<<"], err not exist.\n";\
			return -1;\
		}\
		if( to_value.empty() && !is_empty_ok )\
		{\
			cerr<<"read configure fail[session: "<<session<<", key: "<<key<<"], err empty.\n";\
			return -1;\
		}\
	}while(0)\
	
	#define get_param_int(config, session, key, to_value, is_zero_ok)\
	do{\
		int rv=config.get_int_param(session,key,*(int*)&to_value);\
		if( rv!=0 )\
		{\
			cerr<<"read configure fail[session: "<<session<<", key: "<<key<<"], err not exist\n";\
			return -1;\
		}\
		if( to_value<=0 && !is_zero_ok)\
		{\
			cerr<<"read configure fail[session: "<<session<<", key: "<<key<<"], err zero\n";\
			return -1;\
		}\
	}while(0)\

	#define get_param_size(config, session, key, to_value, is_zero_ok)\
	do{\
		std::string str_size;\
		get_param_str(config, session, key, str_size, is_zero_ok);\
		to_value = Utility::parse_size(str_size.c_str());\
		if( to_value<=0 && !is_zero_ok )\
		{\
			cerr<<"read configure fail[session: "<<session<<", key: "<<key<<"], err zero\n";\
			return -1;\
		}\
	}while(0)\

#endif
